package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.Unit;
import com.nbsaas.boot.product.api.domain.simple.UnitSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 单位-列表对象转换器
*/

public class UnitSimpleConvert implements Converter<UnitSimple, Unit> {




@Override
public UnitSimple convert(Unit source) {
    UnitSimple result = new UnitSimple();

                result.setSymbol(source.getSymbol());
                result.setBaseUnit(source.getBaseUnit());
                result.setNote(source.getNote());
                result.setName(source.getName());
                result.setId(source.getId());
                result.setConversionRate(source.getConversionRate());
                result.setAddDate(source.getAddDate());
                if(source.getStatus()!=null){
                   Map<Integer,String> StatusMap=new HashMap<>();
                       StatusMap.put(1,"启用");
                       StatusMap.put(2,"禁用");
                   String label=  StatusMap.get(source.getStatus());
                   result.setStatusName(label);
                }
                result.setStatus(source.getStatus());
                result.setLastDate(source.getLastDate());


    return result;
}

}